/*
 *  ETA/OS - strchr
 *  Copyright (C) 2014   Michel Megens <dev@bietje.net>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/** @file strchr.c */

#include <etaos/kernel.h>
#include <etaos/string.h>

/**
 * @addtogroup libc
 * @{
 */

/**
 * @brief Find the first occurance of a character.
 * @param str String to search.
 * @param c Character to search for.
 * @return Pointer to the character in \p str if \p c is found, NULL if nothing
 *         was found.
 */
char *strchr(const char *str, int c)
{
	for(;; ++str) {
		if(*str == c)
			return ((char*)str);
		if(!*str)
			return NULL;
	}
}

/** @} */

